using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Diagnostics;
using System.Drawing.Drawing2D;

namespace BPMN.MainWindow
{
    public abstract class EventStart : Event
    {
        public override void updateHotSpots()
        {
            base.updateHotSpots();
        }
        public EventStart(PointF location, SizeF size)
            : base(location, size)
        {


        }
        public EventStart(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {

        }
        public EventStart() : base() { }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            base.Draw(graphics, pen, brush, offset);
            graphics.DrawEllipse(pen, Location.X + offset.X - (int)Size.Width / 2, Location.Y + offset.Y - (int)Size.Height / 2, Size.Width, Size.Height);

        }
    }

    public class EventStartNone : EventStart
    {

        public EventStartNone(PointF location, SizeF size)
            : base(location, size)
        {
        }
        public EventStartNone(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            base.Draw(graphics, pen, brush, offset);

        }
    }

    public class EventStartMessage : EventStart
    {
        public EventStartMessage(PointF location, SizeF size)
            : base(location, size)
        {
        }
        [Constructor]
        public EventStartMessage(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            base.Draw(graphics, pen, brush, offset);
           /* Bitmap b = new Bitmap(480, 640);
            Graphics g = Graphics.FromImage((Image)b);
            g.Clear(Color.White);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.DrawLine(pen, 140, 100, 200 , 200);
            g.DrawRectangle(pen, 100, 100, 300, 300);
            g.DrawRectangle(pen, Location.X + offset.X - (int)Size.Width / 4, Location.Y + offset.Y - (int)Size.Height / 4, 100, 100);
            g.DrawRectangle(pen, Location.X + offset.X - Size.Width / 4, 140 + Location.Y + offset.Y - Size.Height / 4, Size.Width / 2, Size.Width / 2);
            //g.DrawLine(pen, 100 , 100, 100 + offset.X, offset.Y);
           // g.DrawLine(pen, 100 + offset.X + Size.Width / 4, 100 + offset.Y - Size.Height / 4, 100+offset.X, offset.Y);
            graphics.SmoothingMode = SmoothingMode.AntiAlias;*/
            graphics.DrawRectangle(pen, Location.X + offset.X - (int)Size.Width / 4, Location.Y + offset.Y - (int)Size.Height / 4, Size.Width / 2, Size.Width / 2);
            graphics.DrawLine(pen, Location.X + offset.X - Size.Width / 4, Location.Y + offset.Y - Size.Height / 4, Location.X + offset.X, Location.Y + offset.Y);
            graphics.DrawLine(pen, Location.X + offset.X + Size.Width / 4, Location.Y + offset.Y - Size.Height / 4, Location.X + offset.X, Location.Y + offset.Y);

            //b.Save("File.jpg");
        }
    }
    public class EventStartTimer : EventStart
    {
        public EventStartTimer(PointF location, SizeF size)
            : base(location, size)
        {
        }
        [Constructor]
        public EventStartTimer(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            base.Draw(graphics, pen, brush, offset);
            graphics.DrawEllipse(pen, Location.X + offset.X - (int)Size.Width / 4, Location.Y + offset.Y - (int)Size.Height / 4, Size.Width/2, Size.Height/2);
            graphics.DrawLine(pen, Location.X + offset.X, Location.Y + offset.Y, Location.X + offset.X + Size.Width / 5, Location.Y + offset.Y);
            graphics.DrawLine(pen, Location.X + offset.X, Location.Y + offset.Y, Location.X + offset.X + Size.Width / 5 - Size.Width / 10, Location.Y + offset.Y - Size.Height / 6);
            GraphicsPath gp = new GraphicsPath();
            gp.AddLine(BoundingBox.Location.X + offset.X + Size.Width / 2, Location.Y + offset.Y - (int)Size.Height / 4, BoundingBox.Location.X + offset.X + Size.Width / 2, Location.Y + offset.Y - (int)Size.Height / 4+ Size.Height / 13);

            // save a copy of the graphics path so we can reset
            // each time we rotate it.
            GraphicsPath gpOld = new GraphicsPath();
            gpOld = (GraphicsPath)gp.Clone();
            Matrix RotationTransform = new Matrix(1, 0, 0, 1, 0, 0); // rotation matrix
            Matrix TranslationTransform = new Matrix(1, 0, 0, 1, 0, 0); // translation matrix
            //g.DrawEllipse(p,70,70,80,80);
            PointF TheRotationPoint = new PointF(Location.X + offset.X, Location.Y + offset.Y); // rotation point
            for (float f = 0.0f; f < 359.0; f += (float)30.0)
            {
                gp.Transform(TranslationTransform);
                RotationTransform.RotateAt(f, TheRotationPoint);
                gp.Transform(RotationTransform);
                graphics.FillPath(Brushes.Red, gp);
                graphics.DrawPath(pen, gp);
                // reset the transformation matrix
                RotationTransform.Dispose();
                RotationTransform = new Matrix(1, 0, 0, 1, 0, 0);
                // get the original graphics path for our rotation and translation reference
                gp = (GraphicsPath)gpOld.Clone();

            }
        }
    }
    public class EventStartRule : EventStart
    {

        public EventStartRule(PointF location, SizeF size)
            : base(location, size)
        {

        }
        [Constructor]
        public EventStartRule(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            base.Draw(graphics, pen, brush, offset);
            Pen p = new Pen(pen.Color);
            p.Width = Size.Height / 15;
            graphics.DrawRectangle(p, Location.X + offset.X - Size.Width / 4, Location.Y + offset.Y - Size.Height / 4, Size.Width / 2, Size.Height / 2);
            graphics.DrawLine(pen, Location.X + offset.X - Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + Size.Height / 8, Location.X + offset.X + Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + Size.Height / 8);
            graphics.DrawLine(pen, Location.X + offset.X - Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + 2 * Size.Height / 8, Location.X + offset.X + Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + 2 * Size.Height / 8);
            graphics.DrawLine(pen, Location.X + offset.X - Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + 3 * Size.Height / 8, Location.X + offset.X + Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + 3 * Size.Height / 8);
            graphics.DrawLine(pen, Location.X + offset.X - Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + 4 * Size.Height / 8, Location.X + offset.X + Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + 4 * Size.Height / 8);

        }
    }
    public class EventStartLink : EventStart
    {
        public EventStartLink(PointF location, SizeF size)
            : base(location, size)
        {
        }
        [Constructor]
        public EventStartLink(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            base.Draw(graphics, pen, brush, offset);
            GraphicsPath gp = new GraphicsPath();
            PointF[] points = new PointF[4];
            points[0] = new PointF(Location.X + offset.X + Size.Width / 3, Location.Y + offset.Y);
            points[1] = new PointF(Location.X + offset.X + Size.Width / 10, Location.Y + offset.Y + Size.Height / 3);
            points[2] = new PointF(Location.X + offset.X + Size.Width / 10, Location.Y + offset.Y - Size.Height / 3);
            points[3] = new PointF(Location.X + offset.X + Size.Width / 3, Location.Y + offset.Y);
            gp.AddLines(points);
           
            gp.AddRectangle(new RectangleF(Location.X+ offset.X - Size.Width / 3, Location.Y + offset.Y - Size.Height / 8, 2 * Size.Width / 3, Size.Height / 4));
            graphics.FillPath(Variables.DrawingBrush, gp);
           // graphics.FillRectangle(Variables.DrawingBrush, );

        }
    }
    public class EventStartMultiple : EventStart
    {
        public EventStartMultiple(PointF location, SizeF size)
            : base(location, size)
        {
        }
        [Constructor]
        public EventStartMultiple(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {

            base.Draw(graphics, pen, brush, offset);
            GraphicsPath gp = new GraphicsPath();
            PointF[] points = new PointF[4];
            points[0] = new PointF(Location.X + offset.X, Location.Y + offset.Y - Size.Height / (float)2.5);
            points[1] = new PointF(Location.X + offset.X + Size.Width / 3, Location.Y + offset.Y + Size.Height / 5);
            points[2] = new PointF(Location.X + offset.X - Size.Width / 3, Location.Y + offset.Y + Size.Height / 5);
            points[3] = new PointF(Location.X + offset.X, Location.Y + offset.Y - Size.Height / (float)2.5);
            gp.AddLines(points);
            graphics.FillPath(Variables.DrawingBrush, gp);
            GraphicsPath gp2 = new GraphicsPath();
            PointF[] points2 = new PointF[4];
            points2[0] = new PointF(Location.X + offset.X, Location.Y + offset.Y + Size.Height / (float)2.5);
            points2[1] = new PointF(Location.X + offset.X + Size.Width / 3, Location.Y + offset.Y - Size.Height / 5);
            points2[2] = new PointF(Location.X + offset.X - Size.Width / 3, Location.Y + offset.Y - Size.Height / 5);
            points2[3] = new PointF(Location.X + offset.X, Location.Y + offset.Y + Size.Height /(float) 2.5);
            gp2.AddLines(points2);
            graphics.FillPath(Variables.DrawingBrush, gp2);


        }
    }

}
